#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int i = 0;
int Hanoi(int n,char pos1,char pos2,char pos3)
{
	if (n == 1)
	{
		printf(" %c->%c ", pos1, pos3);
		i++;
	}
	else
	{
		Hanoi(n - 1, pos1, pos3, pos2);
		printf(" %c->%c ", pos1, pos3);
		i++;
		Hanoi(n - 1, pos2, pos1, pos3);
	}
	return i;
}
int main()
{
	int n = 0;
	scanf("%d", &n);
	printf("%d", Hanoi(n, 'A', 'B', 'C'));
	return 0;
}